<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>购物车列表 - SXT商城</title>
		<%@ include file="/common/include/title.jsp"%>
		<link type="text/css" href="${rootpath }/css/my.css" rel="stylesheet">
		<link type="text/css" href="${rootpath }/css/list.css" rel="stylesheet">
		<link type="text/css" href="${rootpath }/css/info.css" rel="stylesheet">
	</head>
	<body>
		<div id="doc">
			<%@ include file="/common/include/header.jsp"%>
			<div id="s_bd">
				<div class="stepflow">
					<img src="images/step01.gif" alt="" height="32" width="980">
				</div>
				<div class="addinfo">
					<strong>${requestScope.goods.name } 已添加至购物车。</strong> <a
						href="#">返回继续购物</a>
				</div>
				<!--addinfo end-->
			
				<div class="cartlist">
					<form action="${rootpath }/head/orders/ordersConfirm.htm" method="post">
						<table width="100%">
							<tbody>
								<tr>
									<th width="20"><input onclick="return selectAllFunc('shids','selectAll')" type="checkbox" name="selectAll" id="selectAll" title="全选"/></th>
									<th>序号</th>
									<th>购物车中的商品</th>
									<th>易迅价</th>
									<th>返现</th>
									<th>购买数量</th>
									<th>发货时间</th>
									<th>操作</th>
								</tr>
								<c:set value="0" var="totalPrice"/>
								<c:set value="0" var="totalNum"/>
								<c:set value="0" var="totalFan"/>
								<c:forEach items="${requestScope.shopCarArr }" var="shopCar" varStatus="stat">
									<c:set value="${totalPrice + shopCar.price * shopCar.num }" var="totalPrice"/>
									<c:set value="${totalFan + 0 * shopCar.num }" var="totalFan"/>
									<c:set value="${totalNum + shopCar.num }" var="totalNum"/>
									
									<tr bgcolor="#fffaf1">
										<td width="20"><input type="checkbox" name="shids" value="${shopCar.id}"/></td>
										<td>${stat.count }</td>
										<td>
											<a href="${rootpath }/goods/${shopCar.gid}.htm" target="_blank">
												<c:choose>
													<c:when test="${fn:startsWith(goods.listImgPath,'http')}">
														<img class="smallpic" src="${goods.listImgPath }" alt="" height="80" width="80"></a>
													</c:when>
													<c:when test="${goods.listImgPath != null && goods.listImgPath != ''}">
														<img class="smallpic" src="${websitePath }${goods.listImgPath }" alt="" height="80" width="80"></a>
													</c:when>
													<c:otherwise>
														<img class="smallpic" src="${rootpath }/images/no_pic.jpg" alt="" height="80" width="80"></a>
													</c:otherwise>
												</c:choose>
											</a> 
											<a href="${rootpath }/goods/${shopCar.gid}.htm" target="_blank" title="${shopCar.name}">${fn:substring(shopCar.name,0,20) }</a>
										</td>
										<td><strong class="red">￥${shopCar.price }</strong></td>
										<td>￥0.00</td>
										<td>
											<div class="addinput">
												<input name="qty_item_1" value="${shopCar.num }" id="qty_item_1"
													onkeyup="setAmount.modify('#qty_item_1')" class="stext"
													type="text"> <a class="add"
													onclick="setAmount.add('#qty_item_1')" href="javascript:void(0)"></a>
												<a class="reduce" onclick="setAmount.reduce('#qty_item_1')"
													href="javascript:void(0)"></a>
											</div>
										</td>
										<td>${shopCar.remainNumStr }</td>
										<td><a href="#" class="blue">移入收藏夹</a><br>
										<a href="#" class="blue">删除</a></td>
									</tr>
									
								</c:forEach>
								<tr>
									<td valign="top" colspan="2"><a href="#"><img src="images/deleteicon.gif" /> 清空购物车</a></td>
									<td align="right" colspan="5">
										<p>共${totalNum}件商品，总重3.580kg</p>
										<p style="margin-top:10px;font-size:14px;">
											总计金额(不含运费)：￥${totalPrice}(商品金额) - ￥${totalFan }(返现金额)= 
											<strong style="font-size:18px;color:#d80000;">￥${totalPrice - totalFan }</strong> </p>
									</td>
								</tr>
								<tr>
									<td style="border:none;padding-top:20px;" colspan="7">
										<input type="submit" value="" id="" class="btnimg f-r" />
										<a class="f-r goonbtn" href="#">
											<img src="${rootpath }/images/gooncat.gif" width="86" height="24" alt="" />
										</a>
									</td>
								</tr>
							</tbody>
						</table>
					</form>
				</div>
				<!--cartlist end-->
			
				<script type="text/javascript">
						/* reduce_add */
						var setAmount = {
							min:1,
							max:999,
							reg:function(x) {
								return new RegExp("^[1-9]\\d*$").test(x);
							},
							amount:function(obj, mode) {
								var x = $(obj).val();
								if (this.reg(x)) {
									if (mode) {
										x++;
									} else {
										x--;
									}
								} else {
									alert("请输入正确的数量！");
									$(obj).val(1);
									$(obj).focus();
								}
								return x;
							},
							reduce:function(obj) {
								var x = this.amount(obj, false);
								if (x >= this.min) {
									$(obj).val(x);
								} else {
									alert("商品数量最少为" + this.min);
									$(obj).val(1);
									$(obj).focus();
								}
							},
							add:function(obj) {
								var x = this.amount(obj, true);
								if (x <= this.max) {
									$(obj).val(x);
								} else {
									alert("商品数量最多为" + this.max);
									$(obj).val(999);
									$(obj).focus();
								}
							},
							modify:function(obj) {
								var x = $(obj).val();
								if (x < this.min || x > this.max || !this.reg(x)) {
									alert("请输入正确的数量！");
									$(obj).val(1);
									$(obj).focus();
								}
							}
						}
						</script>
			
			</div>
			<%@ include file="/common/include/footer.jsp"%>
		</div>
	</body>
</html>